import sys
sys.path.append("C:\\Panda3D-1.7.2\\")
from direct.showbase.DirectObject import DirectObject
from direct.task import Task
from pandac.PandaModules import *
from direct.interval.IntervalGlobal import *


class Block():
    def __init__(self):
        # 9/29/2011 Using ODE now
        #self.node = NodePath('physicsNode')
        #self.node.reparentTo(render)
        #self.blockNode = ActorNode('block')
        #self.blockNodePath = self.node.attachNewNode(self.blockNode)       
        #self.block = self.loadObject(loader.loadTexture("../media/block1.png"))
        
        #self.block.setScale(1)
        
        # 9/29/2011 Using ODE now
        #self.block.reparentTo(self.blockNodePath)

        self.blockNodePath.setScale(.5)
        self.blockNodePath.setPos(-1,10,-1.7)
        
    def setPhysics(self):
        # 9/29/2011 Using ODE now
        #self.blockNode.getPhysicsObject().setMass(6)
        #base.physicsMgr.attachPhysicalNode(self.blockNode)
        pass

    def setCollision(self,traverser):
        
        
        #self.ColBox = CollisionBox(0,0,0,1,1,1)
        
        # 9/29/2011 Using ODE now
        #self.ColBox = CollisionSphere(0,0,0,.5)
        #self.ColBoxNodePath = self.block.attachNewNode(CollisionNode('blockbox'))
        #self.ColBoxNodePath.node().addSolid(self.ColBox)
        #self.ColBoxNodePath.show()

        #base.physics.addCollider(self.ColBoxNodePath, self.blockNodePath)
        #base.cTrav.addCollider(self.ColBoxNodePath, base.physics)
        pass

    def loadObject(self, textureobj):
        obj = loader.loadModel("../media/plane")
        obj.reparentTo(render)
        obj.setBin("unsorted", 0)
        obj.setDepthTest(False)
        obj.setScale(.5)
        obj.setTransparency(1)
        obj.setTexture(textureobj, 1)
        return obj
    
    def setXY(self, x, y):
        if x:
            self.block.setX(x)
        if y:
            self.block.setZ(y)


